<?php
/*
 * 心墙后台控制器
 * @author 索索
 */
 
 namespace Admin\Controller;
 use Think\Controller;
 
 class GuestBookController extends CommonController {
 	
//	列表
	public function index() {
		$conds = array();
		$conds['status'] = array('neq',-1);
		
		$page = $_REQUEST['p'] ? $_REQUEST['p'] : 1;
		$pageSize = 10;//每页显示数量
		
		$list = D('GuestBook')->getGuestBook($conds,$page,$pageSize);
		$count = D('GuestBook')->getGuestBookCount($conds);
		$positions = D('Position')->getNormalPositions();
		$res = new \Think\Page($count,$pageSize);
		$pagers = $res->show();
		$this->assign('pagers',$pagers);
		$this->assign('list',$list);
	
		$this->assign('webSiteMenu',D('Menu')->getBarMenus());
		$this->display();
	}
	
//	新增 
	public function add() {
		
	}
	
// 审核
	public function check () {
	  	try{
			if($_POST){
				$id=$_POST['id'];
				$status=$_POST['status'];
				$res=D('GuestBook')->updataStatusById($id,$status);
				if($res){
					return show(1, '审核成功！');
				}else{
					return show(0, '操作失败！');
				}
			}
		}catch(Exception $e){
			return show(0, $e->getMessage());
		}
		return show(0, '没有提交的数据');
	}
	
//	删除
	public function del () {
		try{
			if($_POST){
				$id=$_POST['id'];
				$status=$_POST['status'];
				$res=D('GuestBook')->updataStatusById($id,$status);
				if($res){
					return show(1, '操作成功！');
				}else{
					return show(0, '操作失败！');
				}
			}
		}catch(Exception $e){
			return show(0, $e->getMessage());
		}
		return show(0, '没有提交的数据');
	}
		
}
	
	
	
		
